{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "数据的行数=40\n",
      "数据的列数=11\n",
      "数据的前5行为：\n",
      "        数据库：分省年度数据 Unnamed: 1 Unnamed: 2 Unnamed: 3 Unnamed: 4  \\\n",
      "0  指标：地区生产总值(亿元)        NaN        NaN        NaN        NaN   \n",
      "1            时间：最近10年        NaN        NaN        NaN        NaN   \n",
      "2                      地区     2020年     2019年     2018年     2017年   \n",
      "3                    北京市    36102.6    35445.1      33106      29883   \n",
      "4                    天津市    14083.7    14055.5    13362.9    12450.6   \n",
      "\n",
      "  Unnamed: 5 Unnamed: 6 Unnamed: 7 Unnamed: 8 Unnamed: 9 Unnamed: 10  \n",
      "0        NaN        NaN        NaN        NaN        NaN         NaN  \n",
      "1        NaN        NaN        NaN        NaN        NaN         NaN  \n",
      "2     2016年     2015年     2014年     2013年     2012年      2011年  \n",
      "3    27041.2    24779.1      22926    21134.6    19024.7     17188.8  \n",
      "4    11477.2    10879.5    10640.6     9945.4       9043      8112.5  \n"
     ]
    }
   ],
   "source": [
    "#导入库，设置参数\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "#解除显示宽度的显示，设置数据对齐\n",
    "pd.set_option('display.width',None)\n",
    "pd.set_option('display.unicode.east_asian_width',True)\n",
    "#设置显示字体为黑体，大小15\n",
    "plt.rcParams['font.sans-serif']=['Simhei']\n",
    "plt.rcParams['font.size']=15\n",
    "#导入数据并查看\n",
    "data=pd.read_excel(\"./分省年度数据.xls\")\n",
    "print(\"数据的行数=%d\\n数据的列数=%d\"%(data.shape[0],data.shape[1]))\n",
    "print(\"数据的前5行为：\\n\",data.head())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "数据空值情况为：\n",
      " Unnamed: 1     8\n",
      "Unnamed: 2     8\n",
      "Unnamed: 3     8\n",
      "Unnamed: 4     8\n",
      "Unnamed: 5     8\n",
      "Unnamed: 6     8\n",
      "Unnamed: 7     8\n",
      "Unnamed: 8     8\n",
      "Unnamed: 9     8\n",
      "Unnamed: 10    8\n",
      "dtype: int64\n",
      "去空后的数据的行数= 32\n"
     ]
    }
   ],
   "source": [
    "#数据去空，查看含有空值的列名及对应的空值个数\n",
    "null_result=data.isnull().sum()\n",
    "null_result=null_result.loc[null_result>0]\n",
    "null_result=null_result.sort_values(ascending=False)\n",
    "print(\"数据空值情况为：\\n\",null_result)\n",
    "data=data.dropna(axis=0,subset=['Unnamed: 1'],how='any')\n",
    "print(\"去空后的数据的行数=\",data.shape[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>10</th>\n",
       "      <th>11</th>\n",
       "      <th>...</th>\n",
       "      <th>24</th>\n",
       "      <th>25</th>\n",
       "      <th>26</th>\n",
       "      <th>27</th>\n",
       "      <th>28</th>\n",
       "      <th>29</th>\n",
       "      <th>30</th>\n",
       "      <th>31</th>\n",
       "      <th>32</th>\n",
       "      <th>33</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>数据库：分省年度数据</th>\n",
       "      <td>地区</td>\n",
       "      <td>北京市</td>\n",
       "      <td>天津市</td>\n",
       "      <td>河北省</td>\n",
       "      <td>山西省</td>\n",
       "      <td>内蒙古自治区</td>\n",
       "      <td>辽宁省</td>\n",
       "      <td>吉林省</td>\n",
       "      <td>黑龙江省</td>\n",
       "      <td>上海市</td>\n",
       "      <td>...</td>\n",
       "      <td>重庆市</td>\n",
       "      <td>四川省</td>\n",
       "      <td>贵州省</td>\n",
       "      <td>云南省</td>\n",
       "      <td>西藏自治区</td>\n",
       "      <td>陕西省</td>\n",
       "      <td>甘肃省</td>\n",
       "      <td>青海省</td>\n",
       "      <td>宁夏回族自治区</td>\n",
       "      <td>新疆维吾尔自治区</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 1</th>\n",
       "      <td>2020年</td>\n",
       "      <td>36102.6</td>\n",
       "      <td>14083.7</td>\n",
       "      <td>36206.9</td>\n",
       "      <td>17651.9</td>\n",
       "      <td>17359.8</td>\n",
       "      <td>25115</td>\n",
       "      <td>12311.3</td>\n",
       "      <td>13698.5</td>\n",
       "      <td>38700.6</td>\n",
       "      <td>...</td>\n",
       "      <td>25002.8</td>\n",
       "      <td>48598.8</td>\n",
       "      <td>17826.6</td>\n",
       "      <td>24521.9</td>\n",
       "      <td>1902.7</td>\n",
       "      <td>26181.9</td>\n",
       "      <td>9016.7</td>\n",
       "      <td>3005.9</td>\n",
       "      <td>3920.5</td>\n",
       "      <td>13797.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 2</th>\n",
       "      <td>2019年</td>\n",
       "      <td>35445.1</td>\n",
       "      <td>14055.5</td>\n",
       "      <td>34978.6</td>\n",
       "      <td>16961.6</td>\n",
       "      <td>17212.5</td>\n",
       "      <td>24855.3</td>\n",
       "      <td>11726.8</td>\n",
       "      <td>13544.4</td>\n",
       "      <td>37987.6</td>\n",
       "      <td>...</td>\n",
       "      <td>23605.8</td>\n",
       "      <td>46363.8</td>\n",
       "      <td>16769.3</td>\n",
       "      <td>23223.8</td>\n",
       "      <td>1697.8</td>\n",
       "      <td>25793.2</td>\n",
       "      <td>8718.3</td>\n",
       "      <td>2941.1</td>\n",
       "      <td>3748.5</td>\n",
       "      <td>13597.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 3</th>\n",
       "      <td>2018年</td>\n",
       "      <td>33106</td>\n",
       "      <td>13362.9</td>\n",
       "      <td>32494.6</td>\n",
       "      <td>15958.1</td>\n",
       "      <td>16140.8</td>\n",
       "      <td>23510.5</td>\n",
       "      <td>11253.8</td>\n",
       "      <td>12846.5</td>\n",
       "      <td>36011.8</td>\n",
       "      <td>...</td>\n",
       "      <td>21588.8</td>\n",
       "      <td>42902.1</td>\n",
       "      <td>15353.2</td>\n",
       "      <td>20880.6</td>\n",
       "      <td>1548.4</td>\n",
       "      <td>23941.9</td>\n",
       "      <td>8104.1</td>\n",
       "      <td>2748</td>\n",
       "      <td>3510.2</td>\n",
       "      <td>12809.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 4</th>\n",
       "      <td>2017年</td>\n",
       "      <td>29883</td>\n",
       "      <td>12450.6</td>\n",
       "      <td>30640.8</td>\n",
       "      <td>14484.3</td>\n",
       "      <td>14898.1</td>\n",
       "      <td>21693</td>\n",
       "      <td>10922</td>\n",
       "      <td>12313</td>\n",
       "      <td>32925</td>\n",
       "      <td>...</td>\n",
       "      <td>20066.3</td>\n",
       "      <td>37905.1</td>\n",
       "      <td>13605.4</td>\n",
       "      <td>18486</td>\n",
       "      <td>1349</td>\n",
       "      <td>21473.5</td>\n",
       "      <td>7336.7</td>\n",
       "      <td>2465.1</td>\n",
       "      <td>3200.3</td>\n",
       "      <td>11159.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 5</th>\n",
       "      <td>2016年</td>\n",
       "      <td>27041.2</td>\n",
       "      <td>11477.2</td>\n",
       "      <td>28474.1</td>\n",
       "      <td>11946.4</td>\n",
       "      <td>13789.3</td>\n",
       "      <td>20392.5</td>\n",
       "      <td>10427</td>\n",
       "      <td>11895</td>\n",
       "      <td>29887</td>\n",
       "      <td>...</td>\n",
       "      <td>18023</td>\n",
       "      <td>33138.5</td>\n",
       "      <td>11792.4</td>\n",
       "      <td>16369</td>\n",
       "      <td>1173</td>\n",
       "      <td>19045.8</td>\n",
       "      <td>6907.9</td>\n",
       "      <td>2258.2</td>\n",
       "      <td>2781.4</td>\n",
       "      <td>9630.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 6</th>\n",
       "      <td>2015年</td>\n",
       "      <td>24779.1</td>\n",
       "      <td>10879.5</td>\n",
       "      <td>26398.4</td>\n",
       "      <td>11836.4</td>\n",
       "      <td>12949</td>\n",
       "      <td>20210.3</td>\n",
       "      <td>10018</td>\n",
       "      <td>11690</td>\n",
       "      <td>26887</td>\n",
       "      <td>...</td>\n",
       "      <td>16040.5</td>\n",
       "      <td>30342</td>\n",
       "      <td>10541</td>\n",
       "      <td>14960</td>\n",
       "      <td>1043</td>\n",
       "      <td>17898.8</td>\n",
       "      <td>6556.6</td>\n",
       "      <td>2011</td>\n",
       "      <td>2579.4</td>\n",
       "      <td>9306.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 7</th>\n",
       "      <td>2014年</td>\n",
       "      <td>22926</td>\n",
       "      <td>10640.6</td>\n",
       "      <td>25208.9</td>\n",
       "      <td>12094.7</td>\n",
       "      <td>12158.2</td>\n",
       "      <td>20025.7</td>\n",
       "      <td>9966.5</td>\n",
       "      <td>12170.8</td>\n",
       "      <td>25269.8</td>\n",
       "      <td>...</td>\n",
       "      <td>14623.8</td>\n",
       "      <td>28891.3</td>\n",
       "      <td>9173.1</td>\n",
       "      <td>14041.7</td>\n",
       "      <td>939.7</td>\n",
       "      <td>17402.5</td>\n",
       "      <td>6518.4</td>\n",
       "      <td>1847.7</td>\n",
       "      <td>2473.9</td>\n",
       "      <td>9264.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 8</th>\n",
       "      <td>2013年</td>\n",
       "      <td>21134.6</td>\n",
       "      <td>9945.4</td>\n",
       "      <td>24259.6</td>\n",
       "      <td>11987.2</td>\n",
       "      <td>11392.4</td>\n",
       "      <td>19208.8</td>\n",
       "      <td>9427.9</td>\n",
       "      <td>11849.1</td>\n",
       "      <td>23204.1</td>\n",
       "      <td>...</td>\n",
       "      <td>13027.6</td>\n",
       "      <td>26518</td>\n",
       "      <td>7973.1</td>\n",
       "      <td>12825.5</td>\n",
       "      <td>828.2</td>\n",
       "      <td>15905.4</td>\n",
       "      <td>6014.5</td>\n",
       "      <td>1713.3</td>\n",
       "      <td>2327.7</td>\n",
       "      <td>8392.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 9</th>\n",
       "      <td>2012年</td>\n",
       "      <td>19024.7</td>\n",
       "      <td>9043</td>\n",
       "      <td>23077.5</td>\n",
       "      <td>11683.1</td>\n",
       "      <td>10470.1</td>\n",
       "      <td>17848.6</td>\n",
       "      <td>8678</td>\n",
       "      <td>11015.8</td>\n",
       "      <td>21305.6</td>\n",
       "      <td>...</td>\n",
       "      <td>11595.4</td>\n",
       "      <td>23922.4</td>\n",
       "      <td>6742.2</td>\n",
       "      <td>11097.4</td>\n",
       "      <td>710.2</td>\n",
       "      <td>14142.4</td>\n",
       "      <td>5393.1</td>\n",
       "      <td>1528.5</td>\n",
       "      <td>2131</td>\n",
       "      <td>7411.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 10</th>\n",
       "      <td>2011年</td>\n",
       "      <td>17188.8</td>\n",
       "      <td>8112.5</td>\n",
       "      <td>21384.7</td>\n",
       "      <td>10894.4</td>\n",
       "      <td>9458.1</td>\n",
       "      <td>16354.9</td>\n",
       "      <td>7734.6</td>\n",
       "      <td>9935</td>\n",
       "      <td>20009.7</td>\n",
       "      <td>...</td>\n",
       "      <td>10161.2</td>\n",
       "      <td>21050.9</td>\n",
       "      <td>5615.6</td>\n",
       "      <td>9523.1</td>\n",
       "      <td>611.5</td>\n",
       "      <td>12175.1</td>\n",
       "      <td>4816.9</td>\n",
       "      <td>1370.4</td>\n",
       "      <td>1931.8</td>\n",
       "      <td>6532</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>11 rows × 32 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                          2        3        4        5        6   \\\n",
       "数据库：分省年度数据    地区   北京市   天津市   河北省   山西省   \n",
       "Unnamed: 1            2020年  36102.6  14083.7  36206.9  17651.9   \n",
       "Unnamed: 2            2019年  35445.1  14055.5  34978.6  16961.6   \n",
       "Unnamed: 3            2018年    33106  13362.9  32494.6  15958.1   \n",
       "Unnamed: 4            2017年    29883  12450.6  30640.8  14484.3   \n",
       "Unnamed: 5            2016年  27041.2  11477.2  28474.1  11946.4   \n",
       "Unnamed: 6            2015年  24779.1  10879.5  26398.4  11836.4   \n",
       "Unnamed: 7            2014年    22926  10640.6  25208.9  12094.7   \n",
       "Unnamed: 8            2013年  21134.6   9945.4  24259.6  11987.2   \n",
       "Unnamed: 9            2012年  19024.7     9043  23077.5  11683.1   \n",
       "Unnamed: 10           2011年  17188.8   8112.5  21384.7  10894.4   \n",
       "\n",
       "                                7        8        9         10       11  ...  \\\n",
       "数据库：分省年度数据  内蒙古自治区   辽宁省   吉林省  黑龙江省   上海市  ...   \n",
       "Unnamed: 1                 17359.8    25115  12311.3   13698.5  38700.6  ...   \n",
       "Unnamed: 2                 17212.5  24855.3  11726.8   13544.4  37987.6  ...   \n",
       "Unnamed: 3                 16140.8  23510.5  11253.8   12846.5  36011.8  ...   \n",
       "Unnamed: 4                 14898.1    21693    10922     12313    32925  ...   \n",
       "Unnamed: 5                 13789.3  20392.5    10427     11895    29887  ...   \n",
       "Unnamed: 6                   12949  20210.3    10018     11690    26887  ...   \n",
       "Unnamed: 7                 12158.2  20025.7   9966.5   12170.8  25269.8  ...   \n",
       "Unnamed: 8                 11392.4  19208.8   9427.9   11849.1  23204.1  ...   \n",
       "Unnamed: 9                 10470.1  17848.6     8678   11015.8  21305.6  ...   \n",
       "Unnamed: 10                 9458.1  16354.9   7734.6      9935  20009.7  ...   \n",
       "\n",
       "                           24       25       26       27          28       29  \\\n",
       "数据库：分省年度数据   重庆市   四川省   贵州省   云南省  西藏自治区   陕西省   \n",
       "Unnamed: 1            25002.8  48598.8  17826.6  24521.9      1902.7  26181.9   \n",
       "Unnamed: 2            23605.8  46363.8  16769.3  23223.8      1697.8  25793.2   \n",
       "Unnamed: 3            21588.8  42902.1  15353.2  20880.6      1548.4  23941.9   \n",
       "Unnamed: 4            20066.3  37905.1  13605.4    18486        1349  21473.5   \n",
       "Unnamed: 5              18023  33138.5  11792.4    16369        1173  19045.8   \n",
       "Unnamed: 6            16040.5    30342    10541    14960        1043  17898.8   \n",
       "Unnamed: 7            14623.8  28891.3   9173.1  14041.7       939.7  17402.5   \n",
       "Unnamed: 8            13027.6    26518   7973.1  12825.5       828.2  15905.4   \n",
       "Unnamed: 9            11595.4  23922.4   6742.2  11097.4       710.2  14142.4   \n",
       "Unnamed: 10           10161.2  21050.9   5615.6   9523.1       611.5  12175.1   \n",
       "\n",
       "                          30      31              32                33  \n",
       "数据库：分省年度数据  甘肃省  青海省  宁夏回族自治区  新疆维吾尔自治区  \n",
       "Unnamed: 1            9016.7  3005.9          3920.5           13797.6  \n",
       "Unnamed: 2            8718.3  2941.1          3748.5           13597.1  \n",
       "Unnamed: 3            8104.1    2748          3510.2           12809.4  \n",
       "Unnamed: 4            7336.7  2465.1          3200.3           11159.9  \n",
       "Unnamed: 5            6907.9  2258.2          2781.4            9630.8  \n",
       "Unnamed: 6            6556.6    2011          2579.4            9306.9  \n",
       "Unnamed: 7            6518.4  1847.7          2473.9            9264.5  \n",
       "Unnamed: 8            6014.5  1713.3          2327.7            8392.6  \n",
       "Unnamed: 9            5393.1  1528.5            2131            7411.8  \n",
       "Unnamed: 10           4816.9  1370.4          1931.8              6532  \n",
       "\n",
       "[11 rows x 32 columns]"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = data.T\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>地区</th>\n",
       "      <th>北京市</th>\n",
       "      <th>天津市</th>\n",
       "      <th>河北省</th>\n",
       "      <th>山西省</th>\n",
       "      <th>内蒙古自治区</th>\n",
       "      <th>辽宁省</th>\n",
       "      <th>吉林省</th>\n",
       "      <th>黑龙江省</th>\n",
       "      <th>上海市</th>\n",
       "      <th>...</th>\n",
       "      <th>重庆市</th>\n",
       "      <th>四川省</th>\n",
       "      <th>贵州省</th>\n",
       "      <th>云南省</th>\n",
       "      <th>西藏自治区</th>\n",
       "      <th>陕西省</th>\n",
       "      <th>甘肃省</th>\n",
       "      <th>青海省</th>\n",
       "      <th>宁夏回族自治区</th>\n",
       "      <th>新疆维吾尔自治区</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Unnamed: 1</th>\n",
       "      <td>2020年</td>\n",
       "      <td>36102.6</td>\n",
       "      <td>14083.7</td>\n",
       "      <td>36206.9</td>\n",
       "      <td>17651.9</td>\n",
       "      <td>17359.8</td>\n",
       "      <td>25115</td>\n",
       "      <td>12311.3</td>\n",
       "      <td>13698.5</td>\n",
       "      <td>38700.6</td>\n",
       "      <td>...</td>\n",
       "      <td>25002.8</td>\n",
       "      <td>48598.8</td>\n",
       "      <td>17826.6</td>\n",
       "      <td>24521.9</td>\n",
       "      <td>1902.7</td>\n",
       "      <td>26181.9</td>\n",
       "      <td>9016.7</td>\n",
       "      <td>3005.9</td>\n",
       "      <td>3920.5</td>\n",
       "      <td>13797.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 2</th>\n",
       "      <td>2019年</td>\n",
       "      <td>35445.1</td>\n",
       "      <td>14055.5</td>\n",
       "      <td>34978.6</td>\n",
       "      <td>16961.6</td>\n",
       "      <td>17212.5</td>\n",
       "      <td>24855.3</td>\n",
       "      <td>11726.8</td>\n",
       "      <td>13544.4</td>\n",
       "      <td>37987.6</td>\n",
       "      <td>...</td>\n",
       "      <td>23605.8</td>\n",
       "      <td>46363.8</td>\n",
       "      <td>16769.3</td>\n",
       "      <td>23223.8</td>\n",
       "      <td>1697.8</td>\n",
       "      <td>25793.2</td>\n",
       "      <td>8718.3</td>\n",
       "      <td>2941.1</td>\n",
       "      <td>3748.5</td>\n",
       "      <td>13597.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 3</th>\n",
       "      <td>2018年</td>\n",
       "      <td>33106</td>\n",
       "      <td>13362.9</td>\n",
       "      <td>32494.6</td>\n",
       "      <td>15958.1</td>\n",
       "      <td>16140.8</td>\n",
       "      <td>23510.5</td>\n",
       "      <td>11253.8</td>\n",
       "      <td>12846.5</td>\n",
       "      <td>36011.8</td>\n",
       "      <td>...</td>\n",
       "      <td>21588.8</td>\n",
       "      <td>42902.1</td>\n",
       "      <td>15353.2</td>\n",
       "      <td>20880.6</td>\n",
       "      <td>1548.4</td>\n",
       "      <td>23941.9</td>\n",
       "      <td>8104.1</td>\n",
       "      <td>2748</td>\n",
       "      <td>3510.2</td>\n",
       "      <td>12809.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 4</th>\n",
       "      <td>2017年</td>\n",
       "      <td>29883</td>\n",
       "      <td>12450.6</td>\n",
       "      <td>30640.8</td>\n",
       "      <td>14484.3</td>\n",
       "      <td>14898.1</td>\n",
       "      <td>21693</td>\n",
       "      <td>10922</td>\n",
       "      <td>12313</td>\n",
       "      <td>32925</td>\n",
       "      <td>...</td>\n",
       "      <td>20066.3</td>\n",
       "      <td>37905.1</td>\n",
       "      <td>13605.4</td>\n",
       "      <td>18486</td>\n",
       "      <td>1349</td>\n",
       "      <td>21473.5</td>\n",
       "      <td>7336.7</td>\n",
       "      <td>2465.1</td>\n",
       "      <td>3200.3</td>\n",
       "      <td>11159.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 5</th>\n",
       "      <td>2016年</td>\n",
       "      <td>27041.2</td>\n",
       "      <td>11477.2</td>\n",
       "      <td>28474.1</td>\n",
       "      <td>11946.4</td>\n",
       "      <td>13789.3</td>\n",
       "      <td>20392.5</td>\n",
       "      <td>10427</td>\n",
       "      <td>11895</td>\n",
       "      <td>29887</td>\n",
       "      <td>...</td>\n",
       "      <td>18023</td>\n",
       "      <td>33138.5</td>\n",
       "      <td>11792.4</td>\n",
       "      <td>16369</td>\n",
       "      <td>1173</td>\n",
       "      <td>19045.8</td>\n",
       "      <td>6907.9</td>\n",
       "      <td>2258.2</td>\n",
       "      <td>2781.4</td>\n",
       "      <td>9630.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 6</th>\n",
       "      <td>2015年</td>\n",
       "      <td>24779.1</td>\n",
       "      <td>10879.5</td>\n",
       "      <td>26398.4</td>\n",
       "      <td>11836.4</td>\n",
       "      <td>12949</td>\n",
       "      <td>20210.3</td>\n",
       "      <td>10018</td>\n",
       "      <td>11690</td>\n",
       "      <td>26887</td>\n",
       "      <td>...</td>\n",
       "      <td>16040.5</td>\n",
       "      <td>30342</td>\n",
       "      <td>10541</td>\n",
       "      <td>14960</td>\n",
       "      <td>1043</td>\n",
       "      <td>17898.8</td>\n",
       "      <td>6556.6</td>\n",
       "      <td>2011</td>\n",
       "      <td>2579.4</td>\n",
       "      <td>9306.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 7</th>\n",
       "      <td>2014年</td>\n",
       "      <td>22926</td>\n",
       "      <td>10640.6</td>\n",
       "      <td>25208.9</td>\n",
       "      <td>12094.7</td>\n",
       "      <td>12158.2</td>\n",
       "      <td>20025.7</td>\n",
       "      <td>9966.5</td>\n",
       "      <td>12170.8</td>\n",
       "      <td>25269.8</td>\n",
       "      <td>...</td>\n",
       "      <td>14623.8</td>\n",
       "      <td>28891.3</td>\n",
       "      <td>9173.1</td>\n",
       "      <td>14041.7</td>\n",
       "      <td>939.7</td>\n",
       "      <td>17402.5</td>\n",
       "      <td>6518.4</td>\n",
       "      <td>1847.7</td>\n",
       "      <td>2473.9</td>\n",
       "      <td>9264.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 8</th>\n",
       "      <td>2013年</td>\n",
       "      <td>21134.6</td>\n",
       "      <td>9945.4</td>\n",
       "      <td>24259.6</td>\n",
       "      <td>11987.2</td>\n",
       "      <td>11392.4</td>\n",
       "      <td>19208.8</td>\n",
       "      <td>9427.9</td>\n",
       "      <td>11849.1</td>\n",
       "      <td>23204.1</td>\n",
       "      <td>...</td>\n",
       "      <td>13027.6</td>\n",
       "      <td>26518</td>\n",
       "      <td>7973.1</td>\n",
       "      <td>12825.5</td>\n",
       "      <td>828.2</td>\n",
       "      <td>15905.4</td>\n",
       "      <td>6014.5</td>\n",
       "      <td>1713.3</td>\n",
       "      <td>2327.7</td>\n",
       "      <td>8392.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 9</th>\n",
       "      <td>2012年</td>\n",
       "      <td>19024.7</td>\n",
       "      <td>9043</td>\n",
       "      <td>23077.5</td>\n",
       "      <td>11683.1</td>\n",
       "      <td>10470.1</td>\n",
       "      <td>17848.6</td>\n",
       "      <td>8678</td>\n",
       "      <td>11015.8</td>\n",
       "      <td>21305.6</td>\n",
       "      <td>...</td>\n",
       "      <td>11595.4</td>\n",
       "      <td>23922.4</td>\n",
       "      <td>6742.2</td>\n",
       "      <td>11097.4</td>\n",
       "      <td>710.2</td>\n",
       "      <td>14142.4</td>\n",
       "      <td>5393.1</td>\n",
       "      <td>1528.5</td>\n",
       "      <td>2131</td>\n",
       "      <td>7411.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 10</th>\n",
       "      <td>2011年</td>\n",
       "      <td>17188.8</td>\n",
       "      <td>8112.5</td>\n",
       "      <td>21384.7</td>\n",
       "      <td>10894.4</td>\n",
       "      <td>9458.1</td>\n",
       "      <td>16354.9</td>\n",
       "      <td>7734.6</td>\n",
       "      <td>9935</td>\n",
       "      <td>20009.7</td>\n",
       "      <td>...</td>\n",
       "      <td>10161.2</td>\n",
       "      <td>21050.9</td>\n",
       "      <td>5615.6</td>\n",
       "      <td>9523.1</td>\n",
       "      <td>611.5</td>\n",
       "      <td>12175.1</td>\n",
       "      <td>4816.9</td>\n",
       "      <td>1370.4</td>\n",
       "      <td>1931.8</td>\n",
       "      <td>6532</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10 rows × 32 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "               地区   北京市   天津市   河北省   山西省 内蒙古自治区   辽宁省  \\\n",
       "Unnamed: 1   2020年  36102.6  14083.7  36206.9  17651.9      17359.8    25115   \n",
       "Unnamed: 2   2019年  35445.1  14055.5  34978.6  16961.6      17212.5  24855.3   \n",
       "Unnamed: 3   2018年    33106  13362.9  32494.6  15958.1      16140.8  23510.5   \n",
       "Unnamed: 4   2017年    29883  12450.6  30640.8  14484.3      14898.1    21693   \n",
       "Unnamed: 5   2016年  27041.2  11477.2  28474.1  11946.4      13789.3  20392.5   \n",
       "Unnamed: 6   2015年  24779.1  10879.5  26398.4  11836.4        12949  20210.3   \n",
       "Unnamed: 7   2014年    22926  10640.6  25208.9  12094.7      12158.2  20025.7   \n",
       "Unnamed: 8   2013年  21134.6   9945.4  24259.6  11987.2      11392.4  19208.8   \n",
       "Unnamed: 9   2012年  19024.7     9043  23077.5  11683.1      10470.1  17848.6   \n",
       "Unnamed: 10  2011年  17188.8   8112.5  21384.7  10894.4       9458.1  16354.9   \n",
       "\n",
       "              吉林省 黑龙江省   上海市  ...   重庆市   四川省   贵州省  \\\n",
       "Unnamed: 1   12311.3  13698.5  38700.6  ...  25002.8  48598.8  17826.6   \n",
       "Unnamed: 2   11726.8  13544.4  37987.6  ...  23605.8  46363.8  16769.3   \n",
       "Unnamed: 3   11253.8  12846.5  36011.8  ...  21588.8  42902.1  15353.2   \n",
       "Unnamed: 4     10922    12313    32925  ...  20066.3  37905.1  13605.4   \n",
       "Unnamed: 5     10427    11895    29887  ...    18023  33138.5  11792.4   \n",
       "Unnamed: 6     10018    11690    26887  ...  16040.5    30342    10541   \n",
       "Unnamed: 7    9966.5  12170.8  25269.8  ...  14623.8  28891.3   9173.1   \n",
       "Unnamed: 8    9427.9  11849.1  23204.1  ...  13027.6    26518   7973.1   \n",
       "Unnamed: 9      8678  11015.8  21305.6  ...  11595.4  23922.4   6742.2   \n",
       "Unnamed: 10   7734.6     9935  20009.7  ...  10161.2  21050.9   5615.6   \n",
       "\n",
       "              云南省 西藏自治区   陕西省  甘肃省  青海省 宁夏回族自治区  \\\n",
       "Unnamed: 1   24521.9     1902.7  26181.9  9016.7  3005.9         3920.5   \n",
       "Unnamed: 2   23223.8     1697.8  25793.2  8718.3  2941.1         3748.5   \n",
       "Unnamed: 3   20880.6     1548.4  23941.9  8104.1    2748         3510.2   \n",
       "Unnamed: 4     18486       1349  21473.5  7336.7  2465.1         3200.3   \n",
       "Unnamed: 5     16369       1173  19045.8  6907.9  2258.2         2781.4   \n",
       "Unnamed: 6     14960       1043  17898.8  6556.6    2011         2579.4   \n",
       "Unnamed: 7   14041.7      939.7  17402.5  6518.4  1847.7         2473.9   \n",
       "Unnamed: 8   12825.5      828.2  15905.4  6014.5  1713.3         2327.7   \n",
       "Unnamed: 9   11097.4      710.2  14142.4  5393.1  1528.5           2131   \n",
       "Unnamed: 10   9523.1      611.5  12175.1  4816.9  1370.4         1931.8   \n",
       "\n",
       "            新疆维吾尔自治区  \n",
       "Unnamed: 1           13797.6  \n",
       "Unnamed: 2           13597.1  \n",
       "Unnamed: 3           12809.4  \n",
       "Unnamed: 4           11159.9  \n",
       "Unnamed: 5            9630.8  \n",
       "Unnamed: 6            9306.9  \n",
       "Unnamed: 7            9264.5  \n",
       "Unnamed: 8            8392.6  \n",
       "Unnamed: 9            7411.8  \n",
       "Unnamed: 10             6532  \n",
       "\n",
       "[10 rows x 32 columns]"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.columns = data.iloc[0].to_list()\n",
    "data=data[1::]\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "数据的前5行为：\n",
      "                  地区   北京市   天津市   河北省   山西省 内蒙古自治区  \\\n",
      "Unnamed: 1 2020-01-01  36102.6  14083.7  36206.9  17651.9      17359.8   \n",
      "Unnamed: 2 2019-01-01  35445.1  14055.5  34978.6  16961.6      17212.5   \n",
      "Unnamed: 3 2018-01-01    33106  13362.9  32494.6  15958.1      16140.8   \n",
      "Unnamed: 4 2017-01-01    29883  12450.6  30640.8  14484.3      14898.1   \n",
      "Unnamed: 5 2016-01-01  27041.2  11477.2  28474.1  11946.4      13789.3   \n",
      "\n",
      "             辽宁省   吉林省 黑龙江省   上海市  ...   重庆市   四川省  \\\n",
      "Unnamed: 1    25115  12311.3  13698.5  38700.6  ...  25002.8  48598.8   \n",
      "Unnamed: 2  24855.3  11726.8  13544.4  37987.6  ...  23605.8  46363.8   \n",
      "Unnamed: 3  23510.5  11253.8  12846.5  36011.8  ...  21588.8  42902.1   \n",
      "Unnamed: 4    21693    10922    12313    32925  ...  20066.3  37905.1   \n",
      "Unnamed: 5  20392.5    10427    11895    29887  ...    18023  33138.5   \n",
      "\n",
      "             贵州省   云南省 西藏自治区   陕西省  甘肃省  青海省  \\\n",
      "Unnamed: 1  17826.6  24521.9     1902.7  26181.9  9016.7  3005.9   \n",
      "Unnamed: 2  16769.3  23223.8     1697.8  25793.2  8718.3  2941.1   \n",
      "Unnamed: 3  15353.2  20880.6     1548.4  23941.9  8104.1    2748   \n",
      "Unnamed: 4  13605.4    18486       1349  21473.5  7336.7  2465.1   \n",
      "Unnamed: 5  11792.4    16369       1173  19045.8  6907.9  2258.2   \n",
      "\n",
      "           宁夏回族自治区 新疆维吾尔自治区  \n",
      "Unnamed: 1         3920.5          13797.6  \n",
      "Unnamed: 2         3748.5          13597.1  \n",
      "Unnamed: 3         3510.2          12809.4  \n",
      "Unnamed: 4         3200.3          11159.9  \n",
      "Unnamed: 5         2781.4           9630.8  \n",
      "\n",
      "[5 rows x 32 columns]\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\kit\\AppData\\Local\\Temp/ipykernel_6308/1960281735.py:1: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  data['地区']=data['地区'].str[0:4]\n",
      "C:\\Users\\kit\\AppData\\Local\\Temp/ipykernel_6308/1960281735.py:3: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  data['地区']=pd.to_datetime(data['地区'])\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>地区</th>\n",
       "      <th>北京市</th>\n",
       "      <th>天津市</th>\n",
       "      <th>河北省</th>\n",
       "      <th>山西省</th>\n",
       "      <th>内蒙古自治区</th>\n",
       "      <th>辽宁省</th>\n",
       "      <th>吉林省</th>\n",
       "      <th>黑龙江省</th>\n",
       "      <th>上海市</th>\n",
       "      <th>...</th>\n",
       "      <th>重庆市</th>\n",
       "      <th>四川省</th>\n",
       "      <th>贵州省</th>\n",
       "      <th>云南省</th>\n",
       "      <th>西藏自治区</th>\n",
       "      <th>陕西省</th>\n",
       "      <th>甘肃省</th>\n",
       "      <th>青海省</th>\n",
       "      <th>宁夏回族自治区</th>\n",
       "      <th>新疆维吾尔自治区</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Unnamed: 1</th>\n",
       "      <td>2020-01-01</td>\n",
       "      <td>36102.6</td>\n",
       "      <td>14083.7</td>\n",
       "      <td>36206.9</td>\n",
       "      <td>17651.9</td>\n",
       "      <td>17359.8</td>\n",
       "      <td>25115</td>\n",
       "      <td>12311.3</td>\n",
       "      <td>13698.5</td>\n",
       "      <td>38700.6</td>\n",
       "      <td>...</td>\n",
       "      <td>25002.8</td>\n",
       "      <td>48598.8</td>\n",
       "      <td>17826.6</td>\n",
       "      <td>24521.9</td>\n",
       "      <td>1902.7</td>\n",
       "      <td>26181.9</td>\n",
       "      <td>9016.7</td>\n",
       "      <td>3005.9</td>\n",
       "      <td>3920.5</td>\n",
       "      <td>13797.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 2</th>\n",
       "      <td>2019-01-01</td>\n",
       "      <td>35445.1</td>\n",
       "      <td>14055.5</td>\n",
       "      <td>34978.6</td>\n",
       "      <td>16961.6</td>\n",
       "      <td>17212.5</td>\n",
       "      <td>24855.3</td>\n",
       "      <td>11726.8</td>\n",
       "      <td>13544.4</td>\n",
       "      <td>37987.6</td>\n",
       "      <td>...</td>\n",
       "      <td>23605.8</td>\n",
       "      <td>46363.8</td>\n",
       "      <td>16769.3</td>\n",
       "      <td>23223.8</td>\n",
       "      <td>1697.8</td>\n",
       "      <td>25793.2</td>\n",
       "      <td>8718.3</td>\n",
       "      <td>2941.1</td>\n",
       "      <td>3748.5</td>\n",
       "      <td>13597.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 3</th>\n",
       "      <td>2018-01-01</td>\n",
       "      <td>33106</td>\n",
       "      <td>13362.9</td>\n",
       "      <td>32494.6</td>\n",
       "      <td>15958.1</td>\n",
       "      <td>16140.8</td>\n",
       "      <td>23510.5</td>\n",
       "      <td>11253.8</td>\n",
       "      <td>12846.5</td>\n",
       "      <td>36011.8</td>\n",
       "      <td>...</td>\n",
       "      <td>21588.8</td>\n",
       "      <td>42902.1</td>\n",
       "      <td>15353.2</td>\n",
       "      <td>20880.6</td>\n",
       "      <td>1548.4</td>\n",
       "      <td>23941.9</td>\n",
       "      <td>8104.1</td>\n",
       "      <td>2748</td>\n",
       "      <td>3510.2</td>\n",
       "      <td>12809.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 4</th>\n",
       "      <td>2017-01-01</td>\n",
       "      <td>29883</td>\n",
       "      <td>12450.6</td>\n",
       "      <td>30640.8</td>\n",
       "      <td>14484.3</td>\n",
       "      <td>14898.1</td>\n",
       "      <td>21693</td>\n",
       "      <td>10922</td>\n",
       "      <td>12313</td>\n",
       "      <td>32925</td>\n",
       "      <td>...</td>\n",
       "      <td>20066.3</td>\n",
       "      <td>37905.1</td>\n",
       "      <td>13605.4</td>\n",
       "      <td>18486</td>\n",
       "      <td>1349</td>\n",
       "      <td>21473.5</td>\n",
       "      <td>7336.7</td>\n",
       "      <td>2465.1</td>\n",
       "      <td>3200.3</td>\n",
       "      <td>11159.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 5</th>\n",
       "      <td>2016-01-01</td>\n",
       "      <td>27041.2</td>\n",
       "      <td>11477.2</td>\n",
       "      <td>28474.1</td>\n",
       "      <td>11946.4</td>\n",
       "      <td>13789.3</td>\n",
       "      <td>20392.5</td>\n",
       "      <td>10427</td>\n",
       "      <td>11895</td>\n",
       "      <td>29887</td>\n",
       "      <td>...</td>\n",
       "      <td>18023</td>\n",
       "      <td>33138.5</td>\n",
       "      <td>11792.4</td>\n",
       "      <td>16369</td>\n",
       "      <td>1173</td>\n",
       "      <td>19045.8</td>\n",
       "      <td>6907.9</td>\n",
       "      <td>2258.2</td>\n",
       "      <td>2781.4</td>\n",
       "      <td>9630.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 6</th>\n",
       "      <td>2015-01-01</td>\n",
       "      <td>24779.1</td>\n",
       "      <td>10879.5</td>\n",
       "      <td>26398.4</td>\n",
       "      <td>11836.4</td>\n",
       "      <td>12949</td>\n",
       "      <td>20210.3</td>\n",
       "      <td>10018</td>\n",
       "      <td>11690</td>\n",
       "      <td>26887</td>\n",
       "      <td>...</td>\n",
       "      <td>16040.5</td>\n",
       "      <td>30342</td>\n",
       "      <td>10541</td>\n",
       "      <td>14960</td>\n",
       "      <td>1043</td>\n",
       "      <td>17898.8</td>\n",
       "      <td>6556.6</td>\n",
       "      <td>2011</td>\n",
       "      <td>2579.4</td>\n",
       "      <td>9306.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 7</th>\n",
       "      <td>2014-01-01</td>\n",
       "      <td>22926</td>\n",
       "      <td>10640.6</td>\n",
       "      <td>25208.9</td>\n",
       "      <td>12094.7</td>\n",
       "      <td>12158.2</td>\n",
       "      <td>20025.7</td>\n",
       "      <td>9966.5</td>\n",
       "      <td>12170.8</td>\n",
       "      <td>25269.8</td>\n",
       "      <td>...</td>\n",
       "      <td>14623.8</td>\n",
       "      <td>28891.3</td>\n",
       "      <td>9173.1</td>\n",
       "      <td>14041.7</td>\n",
       "      <td>939.7</td>\n",
       "      <td>17402.5</td>\n",
       "      <td>6518.4</td>\n",
       "      <td>1847.7</td>\n",
       "      <td>2473.9</td>\n",
       "      <td>9264.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 8</th>\n",
       "      <td>2013-01-01</td>\n",
       "      <td>21134.6</td>\n",
       "      <td>9945.4</td>\n",
       "      <td>24259.6</td>\n",
       "      <td>11987.2</td>\n",
       "      <td>11392.4</td>\n",
       "      <td>19208.8</td>\n",
       "      <td>9427.9</td>\n",
       "      <td>11849.1</td>\n",
       "      <td>23204.1</td>\n",
       "      <td>...</td>\n",
       "      <td>13027.6</td>\n",
       "      <td>26518</td>\n",
       "      <td>7973.1</td>\n",
       "      <td>12825.5</td>\n",
       "      <td>828.2</td>\n",
       "      <td>15905.4</td>\n",
       "      <td>6014.5</td>\n",
       "      <td>1713.3</td>\n",
       "      <td>2327.7</td>\n",
       "      <td>8392.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 9</th>\n",
       "      <td>2012-01-01</td>\n",
       "      <td>19024.7</td>\n",
       "      <td>9043</td>\n",
       "      <td>23077.5</td>\n",
       "      <td>11683.1</td>\n",
       "      <td>10470.1</td>\n",
       "      <td>17848.6</td>\n",
       "      <td>8678</td>\n",
       "      <td>11015.8</td>\n",
       "      <td>21305.6</td>\n",
       "      <td>...</td>\n",
       "      <td>11595.4</td>\n",
       "      <td>23922.4</td>\n",
       "      <td>6742.2</td>\n",
       "      <td>11097.4</td>\n",
       "      <td>710.2</td>\n",
       "      <td>14142.4</td>\n",
       "      <td>5393.1</td>\n",
       "      <td>1528.5</td>\n",
       "      <td>2131</td>\n",
       "      <td>7411.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 10</th>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>17188.8</td>\n",
       "      <td>8112.5</td>\n",
       "      <td>21384.7</td>\n",
       "      <td>10894.4</td>\n",
       "      <td>9458.1</td>\n",
       "      <td>16354.9</td>\n",
       "      <td>7734.6</td>\n",
       "      <td>9935</td>\n",
       "      <td>20009.7</td>\n",
       "      <td>...</td>\n",
       "      <td>10161.2</td>\n",
       "      <td>21050.9</td>\n",
       "      <td>5615.6</td>\n",
       "      <td>9523.1</td>\n",
       "      <td>611.5</td>\n",
       "      <td>12175.1</td>\n",
       "      <td>4816.9</td>\n",
       "      <td>1370.4</td>\n",
       "      <td>1931.8</td>\n",
       "      <td>6532</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10 rows × 32 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                  地区   北京市   天津市   河北省   山西省 内蒙古自治区  \\\n",
       "Unnamed: 1  2020-01-01  36102.6  14083.7  36206.9  17651.9      17359.8   \n",
       "Unnamed: 2  2019-01-01  35445.1  14055.5  34978.6  16961.6      17212.5   \n",
       "Unnamed: 3  2018-01-01    33106  13362.9  32494.6  15958.1      16140.8   \n",
       "Unnamed: 4  2017-01-01    29883  12450.6  30640.8  14484.3      14898.1   \n",
       "Unnamed: 5  2016-01-01  27041.2  11477.2  28474.1  11946.4      13789.3   \n",
       "Unnamed: 6  2015-01-01  24779.1  10879.5  26398.4  11836.4        12949   \n",
       "Unnamed: 7  2014-01-01    22926  10640.6  25208.9  12094.7      12158.2   \n",
       "Unnamed: 8  2013-01-01  21134.6   9945.4  24259.6  11987.2      11392.4   \n",
       "Unnamed: 9  2012-01-01  19024.7     9043  23077.5  11683.1      10470.1   \n",
       "Unnamed: 10 2011-01-01  17188.8   8112.5  21384.7  10894.4       9458.1   \n",
       "\n",
       "              辽宁省   吉林省 黑龙江省   上海市  ...   重庆市   四川省  \\\n",
       "Unnamed: 1     25115  12311.3  13698.5  38700.6  ...  25002.8  48598.8   \n",
       "Unnamed: 2   24855.3  11726.8  13544.4  37987.6  ...  23605.8  46363.8   \n",
       "Unnamed: 3   23510.5  11253.8  12846.5  36011.8  ...  21588.8  42902.1   \n",
       "Unnamed: 4     21693    10922    12313    32925  ...  20066.3  37905.1   \n",
       "Unnamed: 5   20392.5    10427    11895    29887  ...    18023  33138.5   \n",
       "Unnamed: 6   20210.3    10018    11690    26887  ...  16040.5    30342   \n",
       "Unnamed: 7   20025.7   9966.5  12170.8  25269.8  ...  14623.8  28891.3   \n",
       "Unnamed: 8   19208.8   9427.9  11849.1  23204.1  ...  13027.6    26518   \n",
       "Unnamed: 9   17848.6     8678  11015.8  21305.6  ...  11595.4  23922.4   \n",
       "Unnamed: 10  16354.9   7734.6     9935  20009.7  ...  10161.2  21050.9   \n",
       "\n",
       "              贵州省   云南省 西藏自治区   陕西省  甘肃省  青海省  \\\n",
       "Unnamed: 1   17826.6  24521.9     1902.7  26181.9  9016.7  3005.9   \n",
       "Unnamed: 2   16769.3  23223.8     1697.8  25793.2  8718.3  2941.1   \n",
       "Unnamed: 3   15353.2  20880.6     1548.4  23941.9  8104.1    2748   \n",
       "Unnamed: 4   13605.4    18486       1349  21473.5  7336.7  2465.1   \n",
       "Unnamed: 5   11792.4    16369       1173  19045.8  6907.9  2258.2   \n",
       "Unnamed: 6     10541    14960       1043  17898.8  6556.6    2011   \n",
       "Unnamed: 7    9173.1  14041.7      939.7  17402.5  6518.4  1847.7   \n",
       "Unnamed: 8    7973.1  12825.5      828.2  15905.4  6014.5  1713.3   \n",
       "Unnamed: 9    6742.2  11097.4      710.2  14142.4  5393.1  1528.5   \n",
       "Unnamed: 10   5615.6   9523.1      611.5  12175.1  4816.9  1370.4   \n",
       "\n",
       "            宁夏回族自治区 新疆维吾尔自治区  \n",
       "Unnamed: 1          3920.5          13797.6  \n",
       "Unnamed: 2          3748.5          13597.1  \n",
       "Unnamed: 3          3510.2          12809.4  \n",
       "Unnamed: 4          3200.3          11159.9  \n",
       "Unnamed: 5          2781.4           9630.8  \n",
       "Unnamed: 6          2579.4           9306.9  \n",
       "Unnamed: 7          2473.9           9264.5  \n",
       "Unnamed: 8          2327.7           8392.6  \n",
       "Unnamed: 9            2131           7411.8  \n",
       "Unnamed: 10         1931.8             6532  \n",
       "\n",
       "[10 rows x 32 columns]"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['地区']=data['地区'].str[0:4]\n",
    "#时间序列处理\n",
    "data['地区']=pd.to_datetime(data['地区'])\n",
    "# data['start_time']=pd.to_datetime(data['start_time'])\n",
    "# data['lock_time']=pd.to_datetime(data['lock_time'])\n",
    "# data['deal_time']=data['lock_time']-data['start_time']\n",
    "# data['weekday']=data['start_time'].dt.day_name()\n",
    "print(\"数据的前5行为：\\n\",data.head())\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>地区</th>\n",
       "      <th>北京市</th>\n",
       "      <th>天津市</th>\n",
       "      <th>河北省</th>\n",
       "      <th>山西省</th>\n",
       "      <th>内蒙古自治区</th>\n",
       "      <th>辽宁省</th>\n",
       "      <th>吉林省</th>\n",
       "      <th>黑龙江省</th>\n",
       "      <th>上海市</th>\n",
       "      <th>...</th>\n",
       "      <th>重庆市</th>\n",
       "      <th>四川省</th>\n",
       "      <th>贵州省</th>\n",
       "      <th>云南省</th>\n",
       "      <th>西藏自治区</th>\n",
       "      <th>陕西省</th>\n",
       "      <th>甘肃省</th>\n",
       "      <th>青海省</th>\n",
       "      <th>宁夏回族自治区</th>\n",
       "      <th>新疆维吾尔自治区</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2020-01-01</th>\n",
       "      <td>2020-01-01</td>\n",
       "      <td>36102.6</td>\n",
       "      <td>14083.7</td>\n",
       "      <td>36206.9</td>\n",
       "      <td>17651.9</td>\n",
       "      <td>17359.8</td>\n",
       "      <td>25115</td>\n",
       "      <td>12311.3</td>\n",
       "      <td>13698.5</td>\n",
       "      <td>38700.6</td>\n",
       "      <td>...</td>\n",
       "      <td>25002.8</td>\n",
       "      <td>48598.8</td>\n",
       "      <td>17826.6</td>\n",
       "      <td>24521.9</td>\n",
       "      <td>1902.7</td>\n",
       "      <td>26181.9</td>\n",
       "      <td>9016.7</td>\n",
       "      <td>3005.9</td>\n",
       "      <td>3920.5</td>\n",
       "      <td>13797.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-01</th>\n",
       "      <td>2019-01-01</td>\n",
       "      <td>35445.1</td>\n",
       "      <td>14055.5</td>\n",
       "      <td>34978.6</td>\n",
       "      <td>16961.6</td>\n",
       "      <td>17212.5</td>\n",
       "      <td>24855.3</td>\n",
       "      <td>11726.8</td>\n",
       "      <td>13544.4</td>\n",
       "      <td>37987.6</td>\n",
       "      <td>...</td>\n",
       "      <td>23605.8</td>\n",
       "      <td>46363.8</td>\n",
       "      <td>16769.3</td>\n",
       "      <td>23223.8</td>\n",
       "      <td>1697.8</td>\n",
       "      <td>25793.2</td>\n",
       "      <td>8718.3</td>\n",
       "      <td>2941.1</td>\n",
       "      <td>3748.5</td>\n",
       "      <td>13597.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-01</th>\n",
       "      <td>2018-01-01</td>\n",
       "      <td>33106</td>\n",
       "      <td>13362.9</td>\n",
       "      <td>32494.6</td>\n",
       "      <td>15958.1</td>\n",
       "      <td>16140.8</td>\n",
       "      <td>23510.5</td>\n",
       "      <td>11253.8</td>\n",
       "      <td>12846.5</td>\n",
       "      <td>36011.8</td>\n",
       "      <td>...</td>\n",
       "      <td>21588.8</td>\n",
       "      <td>42902.1</td>\n",
       "      <td>15353.2</td>\n",
       "      <td>20880.6</td>\n",
       "      <td>1548.4</td>\n",
       "      <td>23941.9</td>\n",
       "      <td>8104.1</td>\n",
       "      <td>2748</td>\n",
       "      <td>3510.2</td>\n",
       "      <td>12809.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-01</th>\n",
       "      <td>2017-01-01</td>\n",
       "      <td>29883</td>\n",
       "      <td>12450.6</td>\n",
       "      <td>30640.8</td>\n",
       "      <td>14484.3</td>\n",
       "      <td>14898.1</td>\n",
       "      <td>21693</td>\n",
       "      <td>10922</td>\n",
       "      <td>12313</td>\n",
       "      <td>32925</td>\n",
       "      <td>...</td>\n",
       "      <td>20066.3</td>\n",
       "      <td>37905.1</td>\n",
       "      <td>13605.4</td>\n",
       "      <td>18486</td>\n",
       "      <td>1349</td>\n",
       "      <td>21473.5</td>\n",
       "      <td>7336.7</td>\n",
       "      <td>2465.1</td>\n",
       "      <td>3200.3</td>\n",
       "      <td>11159.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-01-01</th>\n",
       "      <td>2016-01-01</td>\n",
       "      <td>27041.2</td>\n",
       "      <td>11477.2</td>\n",
       "      <td>28474.1</td>\n",
       "      <td>11946.4</td>\n",
       "      <td>13789.3</td>\n",
       "      <td>20392.5</td>\n",
       "      <td>10427</td>\n",
       "      <td>11895</td>\n",
       "      <td>29887</td>\n",
       "      <td>...</td>\n",
       "      <td>18023</td>\n",
       "      <td>33138.5</td>\n",
       "      <td>11792.4</td>\n",
       "      <td>16369</td>\n",
       "      <td>1173</td>\n",
       "      <td>19045.8</td>\n",
       "      <td>6907.9</td>\n",
       "      <td>2258.2</td>\n",
       "      <td>2781.4</td>\n",
       "      <td>9630.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-01-01</th>\n",
       "      <td>2015-01-01</td>\n",
       "      <td>24779.1</td>\n",
       "      <td>10879.5</td>\n",
       "      <td>26398.4</td>\n",
       "      <td>11836.4</td>\n",
       "      <td>12949</td>\n",
       "      <td>20210.3</td>\n",
       "      <td>10018</td>\n",
       "      <td>11690</td>\n",
       "      <td>26887</td>\n",
       "      <td>...</td>\n",
       "      <td>16040.5</td>\n",
       "      <td>30342</td>\n",
       "      <td>10541</td>\n",
       "      <td>14960</td>\n",
       "      <td>1043</td>\n",
       "      <td>17898.8</td>\n",
       "      <td>6556.6</td>\n",
       "      <td>2011</td>\n",
       "      <td>2579.4</td>\n",
       "      <td>9306.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-01-01</th>\n",
       "      <td>2014-01-01</td>\n",
       "      <td>22926</td>\n",
       "      <td>10640.6</td>\n",
       "      <td>25208.9</td>\n",
       "      <td>12094.7</td>\n",
       "      <td>12158.2</td>\n",
       "      <td>20025.7</td>\n",
       "      <td>9966.5</td>\n",
       "      <td>12170.8</td>\n",
       "      <td>25269.8</td>\n",
       "      <td>...</td>\n",
       "      <td>14623.8</td>\n",
       "      <td>28891.3</td>\n",
       "      <td>9173.1</td>\n",
       "      <td>14041.7</td>\n",
       "      <td>939.7</td>\n",
       "      <td>17402.5</td>\n",
       "      <td>6518.4</td>\n",
       "      <td>1847.7</td>\n",
       "      <td>2473.9</td>\n",
       "      <td>9264.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-01</th>\n",
       "      <td>2013-01-01</td>\n",
       "      <td>21134.6</td>\n",
       "      <td>9945.4</td>\n",
       "      <td>24259.6</td>\n",
       "      <td>11987.2</td>\n",
       "      <td>11392.4</td>\n",
       "      <td>19208.8</td>\n",
       "      <td>9427.9</td>\n",
       "      <td>11849.1</td>\n",
       "      <td>23204.1</td>\n",
       "      <td>...</td>\n",
       "      <td>13027.6</td>\n",
       "      <td>26518</td>\n",
       "      <td>7973.1</td>\n",
       "      <td>12825.5</td>\n",
       "      <td>828.2</td>\n",
       "      <td>15905.4</td>\n",
       "      <td>6014.5</td>\n",
       "      <td>1713.3</td>\n",
       "      <td>2327.7</td>\n",
       "      <td>8392.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2012-01-01</th>\n",
       "      <td>2012-01-01</td>\n",
       "      <td>19024.7</td>\n",
       "      <td>9043</td>\n",
       "      <td>23077.5</td>\n",
       "      <td>11683.1</td>\n",
       "      <td>10470.1</td>\n",
       "      <td>17848.6</td>\n",
       "      <td>8678</td>\n",
       "      <td>11015.8</td>\n",
       "      <td>21305.6</td>\n",
       "      <td>...</td>\n",
       "      <td>11595.4</td>\n",
       "      <td>23922.4</td>\n",
       "      <td>6742.2</td>\n",
       "      <td>11097.4</td>\n",
       "      <td>710.2</td>\n",
       "      <td>14142.4</td>\n",
       "      <td>5393.1</td>\n",
       "      <td>1528.5</td>\n",
       "      <td>2131</td>\n",
       "      <td>7411.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-01-01</th>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>17188.8</td>\n",
       "      <td>8112.5</td>\n",
       "      <td>21384.7</td>\n",
       "      <td>10894.4</td>\n",
       "      <td>9458.1</td>\n",
       "      <td>16354.9</td>\n",
       "      <td>7734.6</td>\n",
       "      <td>9935</td>\n",
       "      <td>20009.7</td>\n",
       "      <td>...</td>\n",
       "      <td>10161.2</td>\n",
       "      <td>21050.9</td>\n",
       "      <td>5615.6</td>\n",
       "      <td>9523.1</td>\n",
       "      <td>611.5</td>\n",
       "      <td>12175.1</td>\n",
       "      <td>4816.9</td>\n",
       "      <td>1370.4</td>\n",
       "      <td>1931.8</td>\n",
       "      <td>6532</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10 rows × 32 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                 地区   北京市   天津市   河北省   山西省 内蒙古自治区  \\\n",
       "2020-01-01 2020-01-01  36102.6  14083.7  36206.9  17651.9      17359.8   \n",
       "2019-01-01 2019-01-01  35445.1  14055.5  34978.6  16961.6      17212.5   \n",
       "2018-01-01 2018-01-01    33106  13362.9  32494.6  15958.1      16140.8   \n",
       "2017-01-01 2017-01-01    29883  12450.6  30640.8  14484.3      14898.1   \n",
       "2016-01-01 2016-01-01  27041.2  11477.2  28474.1  11946.4      13789.3   \n",
       "2015-01-01 2015-01-01  24779.1  10879.5  26398.4  11836.4        12949   \n",
       "2014-01-01 2014-01-01    22926  10640.6  25208.9  12094.7      12158.2   \n",
       "2013-01-01 2013-01-01  21134.6   9945.4  24259.6  11987.2      11392.4   \n",
       "2012-01-01 2012-01-01  19024.7     9043  23077.5  11683.1      10470.1   \n",
       "2011-01-01 2011-01-01  17188.8   8112.5  21384.7  10894.4       9458.1   \n",
       "\n",
       "             辽宁省   吉林省 黑龙江省   上海市  ...   重庆市   四川省  \\\n",
       "2020-01-01    25115  12311.3  13698.5  38700.6  ...  25002.8  48598.8   \n",
       "2019-01-01  24855.3  11726.8  13544.4  37987.6  ...  23605.8  46363.8   \n",
       "2018-01-01  23510.5  11253.8  12846.5  36011.8  ...  21588.8  42902.1   \n",
       "2017-01-01    21693    10922    12313    32925  ...  20066.3  37905.1   \n",
       "2016-01-01  20392.5    10427    11895    29887  ...    18023  33138.5   \n",
       "2015-01-01  20210.3    10018    11690    26887  ...  16040.5    30342   \n",
       "2014-01-01  20025.7   9966.5  12170.8  25269.8  ...  14623.8  28891.3   \n",
       "2013-01-01  19208.8   9427.9  11849.1  23204.1  ...  13027.6    26518   \n",
       "2012-01-01  17848.6     8678  11015.8  21305.6  ...  11595.4  23922.4   \n",
       "2011-01-01  16354.9   7734.6     9935  20009.7  ...  10161.2  21050.9   \n",
       "\n",
       "             贵州省   云南省 西藏自治区   陕西省  甘肃省  青海省  \\\n",
       "2020-01-01  17826.6  24521.9     1902.7  26181.9  9016.7  3005.9   \n",
       "2019-01-01  16769.3  23223.8     1697.8  25793.2  8718.3  2941.1   \n",
       "2018-01-01  15353.2  20880.6     1548.4  23941.9  8104.1    2748   \n",
       "2017-01-01  13605.4    18486       1349  21473.5  7336.7  2465.1   \n",
       "2016-01-01  11792.4    16369       1173  19045.8  6907.9  2258.2   \n",
       "2015-01-01    10541    14960       1043  17898.8  6556.6    2011   \n",
       "2014-01-01   9173.1  14041.7      939.7  17402.5  6518.4  1847.7   \n",
       "2013-01-01   7973.1  12825.5      828.2  15905.4  6014.5  1713.3   \n",
       "2012-01-01   6742.2  11097.4      710.2  14142.4  5393.1  1528.5   \n",
       "2011-01-01   5615.6   9523.1      611.5  12175.1  4816.9  1370.4   \n",
       "\n",
       "           宁夏回族自治区 新疆维吾尔自治区  \n",
       "2020-01-01         3920.5          13797.6  \n",
       "2019-01-01         3748.5          13597.1  \n",
       "2018-01-01         3510.2          12809.4  \n",
       "2017-01-01         3200.3          11159.9  \n",
       "2016-01-01         2781.4           9630.8  \n",
       "2015-01-01         2579.4           9306.9  \n",
       "2014-01-01         2473.9           9264.5  \n",
       "2013-01-01         2327.7           8392.6  \n",
       "2012-01-01           2131           7411.8  \n",
       "2011-01-01         1931.8             6532  \n",
       "\n",
       "[10 rows x 32 columns]"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# data.index = data.loc[0].to_list()\n",
    "# data\n",
    "data.index=data['地区'].to_list()\n",
    "data"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "c3ac3f88986c03f5f4ea9b167d463bfb61b25cb597313235fabe727a0f7e0da2"
  },
  "kernelspec": {
   "display_name": "Python 3.9.5 64-bit ('base': conda)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.5"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
